<?php

class SearchItem extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'v_search_form':
	 * @var integer $project_id
	 * @var string $activity
	 * @var string $description
	 * @var string $route_mnemonic
	 * @var integer $owner_id
	 * @var string $first_name
	 * @var string $last_name
	 * @var string $gender
	 * @var string $birth_date
	 * @var integer $city_id
	 * @var string $email
	 * @var string $referent
	 * @var string $adviser_initials
	 * @var string $city_name
	 * @var string $postal_code
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'v_search_form';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		return array(
			array('activity','length','max'=>255),
			array('route_mnemonic','length','max'=>5),
			array('first_name','length','max'=>100),
			array('last_name','length','max'=>100),
			array('gender','length','max'=>5),
			array('email','length','max'=>255),
			array('referent','length','max'=>255),
			array('adviser_initials','length','max'=>3),
			array('city_name','length','max'=>255),
			array('postal_code','length','max'=>10),
			array('activity, route_mnemonic, first_name, birth_date, city_id, adviser_initials, city_name, postal_code', 'required'),
			array('project_id, owner_id, city_id', 'numerical', 'integerOnly'=>true),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
//			'service' => array(self::BELONGS_TO, 'Service', 'service_id'),
			'city' => array(self::BELONGS_TO, 'City', 'city_id'),
			'adviser' => array(self::BELONGS_TO, 'Adviser', 'adviser_initials'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'project_id' => 'Project',
			'activity' => 'Activity',
			'description' => 'Description',
			'route_mnemonic' => 'Route Mnemonic',
			'owner_id' => 'Owner',
			'first_name' => 'First Name',
			'last_name' => 'Last Name',
			'gender' => 'Gender',
			'birth_date' => 'Birth Date',
			'city_id' => 'City Id',
			'email' => 'Email',
			'referent' => 'Referent',
			'adviser_initials' => 'Adviser Initials',
			'city_name' => 'City Name',
			'postal_code' => 'Postal Code',
		);
	}
}